<!-- Phan khai bao bien cuc bo-->
<?php
if(isset($_REQUEST['hdn_worktype'])) {
	$v_worktype = $_REQUEST['hdn_worktype'];
}else{
	$v_worktype = "";
}

//Xac dinh xem can bo thu ly co ky duyet thay Lanh dao khong
if(isset($_REQUEST['hdn_approve_by_handler'])) {
	$v_approve_by_handler = true;
}else{
	$v_approve_by_handler = false;
}
//Bien cho phep an/hien option "Chuyen co quan co tham quyen giai quyet" va "Trinh lanh dao ky giay phep"
$v_tranfered = 0;
$v_num = '';
$v_dem = -1;
if(isset($_REQUEST['hdn_tranfered'])){
	$v_tranfered = $_REQUEST['hdn_tranfered'];
}
//echo 'v_tranfered' . $v_tranfered . '<br>';

$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
$v_staff_id = $_SESSION['staff_id'];
$v_current_status_string = "";
$v_current_status = ($arr_all_record[0][2]);

//echo "v_current_status = ".$v_current_status;
if( $v_current_status == "TRANH_CHAP"){
	$v_current_status_string  = CONST_RECORD_STATUS_TRANHCHAP;
}
else {
	$v_current_status_string = CONST_RECORD_STATUS_HETTRANHCHAP;
}


//---------------------End----------------------------------
$v_recordtype_name = Get_text_from_array($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','C_NAME',$v_recordtype_filter);
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_code_list = $_REQUEST['hdn_record_id_list'];
}
$v_record_code_list='';
//echo $v_record_code_list;

//echo "v_handler_name = ".$v_handler_name ;exit;

$v_update_status = true;	// DinhNQ Added 10-07-2007
for($row_index = 0;$row_index< $v_count;$row_index++){
	if ($row_index<$v_count-1)
		$v_record_code_list = $v_record_code_list.$arr_all_record[$row_index][0].", ";
		//echo $v_record_code_list ;
	else
		$v_record_code_list = $v_record_code_list.$arr_all_record[$row_index][0];
		$v_handler_id = intval($arr_all_record[$row_index][4]);	// capture FK_HANDLER
		$v_recieved_date = _yyyymmdd_to_ddmmyyyy($arr_all_record[$row_index][5]);		// ngay tiep nhan (nieuvv--150908)
	//---------- Update by Dinh, Nguyen ---------
	//--- Date: 10/07/2007 ----------------------
	// Content: Click lom chom ------------------
	/* Kiem tra xem co quyen cap nhat trang thai ket quan thu ly khong? */
	//echo "staff_id: ", $v_staff_id, " --- handler_id: ", $v_handler_id;
	if($v_staff_id != $v_handler_id)	// NEU KHONG PHAI LA NGUOI THU LY THI BANG FALSE
		$v_update_status = false;

}

// xac dinh label hien thi: trinh ky, duoc giai quyet, khong duoc giai quyet
$arr_result_label = onegate_get_label_of_result_type($_SESSION['recordtype'],$v_recordtype_filter);

$v_work_date = date("d/m/Y");

?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">
	<tr class="large_title">
		<td><?php 
			if ($v_approve_by_handler) { 
				echo CONST_UPDATE_STATUS_DISPUTE;
			}else
				echo CONST_UPDATE_STATUS_DISPUTE;
			?></td>
	</tr>
</table>
<!-- Bat cac phim: F12=true; Insert=false; Delete=false, ESC=true; Enter=true -->
<div id="hotkey" onKeyDown="javascript:process_hot_key(true,false,false,true,true);">
<!--bang chua cac text box de nhap du lieu-->
<table width="100%" class="form_table1" cellpadding="0" cellspacing="0">
	<col width="20%"><col width="60%"><col width="20%">
	<tr>
		<form action="index.php" method="post" name="f_record_update_status">
		<input type="hidden" name="fuseaction" value="" >
		<!--bien hidden xac dinh can bo thu ly co ky duyet thay Lanh dao khong -->
		<input type="hidden" name="hdn_approve_by_handler" value="<?php echo $v_approve_by_handler?>" >
		<input type="hidden" name="hdn_date_update" value="" >
		<input type="hidden" name="hdn_record_id_list" value="<?php echo $v_record_id_list ?>" >
		<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter;?>">
		<input type="hidden" name="hdn_work" value="">
	</tr>
	<tr>
	<?php /*?><tr>
		<td class="normal_label"><?php echo CONST_RECORD_TYPE_LABEL; ?></td>
		<td><?php echo $v_recordtype_name;?></td>
	</tr><?php */?>
	<tr>
		<td class="normal_label"><?php echo CONST_DATE_DISPUTE?></td>
		<td>
			<input class="normal_date_textbox" name="txt_work_date" type="text" value="<?php echo $v_recieved_date; ?>" optional="true" isdate="true" message="<?php echo _CONST_WORK_DATE_MESSAGE;?>" onKeyDown="change_focus(document.forms[0],this)" readonly>
			<!-- img src="<?php echo $_ISA_IMAGE_URL_PATH;?>calendar.gif" border="0" onclick="DoCal('<?php echo $_ISA_LIB_URL_PATH;?>isa-calendar/',document.forms[0].txt_work_date);" style="cursor:hand" -->
		</td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_LIST_RECORD_HANDLE_DISPUTE; ?></td>
		<td><?php for ($i=0;$i<$v_count;$i++)
					{ 
						$v_fk_user = ($arr_all_record[$i][4]);
						//echo $v_fk_user.'<br>';
						$v_handler_name =_get_item_attr_by_id($_SESSION['arr_all_staff'],$v_fk_user ,'name').',';//Ten can bo 
						echo $v_handler_name ;
					}	 ?>
</td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_LIST_RECORD_STATUS_DISPUTE; ?></td>
		<td><?php echo $v_current_status_string;?></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_DATE_END_DISPUTE?></td>
		<td>
			<input class="normal_date_textbox" name="txt_work_date1" type="text" value="<?php echo $v_work_date; ?>" optional="true" isdate="true" message="<?php echo _CONST_WORK_DATE_MESSAGE;?>" onKeyDown="change_focus(document.forms[0],this)" readonly>
			 <img src="<?php echo $_ISA_IMAGE_URL_PATH;?>calendar.gif" border="0" onclick="DoCal('<?php echo $_ISA_LIB_URL_PATH;?>isa-calendar/',document.forms[0].txt_work_date1);refuse_onclick(this,document.forms[0].hdn_date_update);" style="cursor:hand" />
		</td>
	</tr>
	<tr class="normal_label">
		<td class="normal_label"><?php echo CONST_RESULT_HANDLE_RECORD_STATUS_DISPUTE; ?></td>
		<td><input type="radio" name="rad_status" value="TRANH_CHAP" onclick="refuse_onclick(this,document.forms[0].hdn_work);" optional="true"><?php echo CONST_TITLE_TRANH_CHAP;$v_dem++; ?></td>
	</tr>
	<tr class="normal_label">
		<td height="37"></td>
		<td><input type="radio" name="rad_status" value="HET_TRANH_CHAP" onclick="refuse_onclick(this,document.forms[0].hdn_work);set_value_for_obj(document.forms[0].txt_reason,'<?php echo $v_reason;?>')" optional="true"><?php echo CONST_TITLE_HET_TRANH_CHAP; $v_dem++; if($v_num!='') $v_num = $v_num.','.$v_dem; else $v_num = $v_dem;?></td>
	</tr>
	<tr id="tr_reason" class="normal_label" style="display:none">
		<td height="37"><?php echo CONST_RECORD_REASON_LABEL; ?></td>
		<td><textarea name="txt_reason" class="normal_textarea" value="" row="4" style="width:100%" optional="true" message=""></textarea></td>
	</tr>
</table>
<!--bang chua cac button-->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td>&nbsp;</td></tr>
	<tr align="center">
		<td>
		<?php 
		//../isa-lib/isa-public_function/updateConflictRecords(..)
		$is_dsp_buttonUpdate=updateConflictRecords($_IS_APPROVING,$v_staff_id,$arrs_creater_conflictRecords);
		if($is_dsp_buttonUpdate){ ?>
		<input type='button' class='normal_button' name="btn_update_NgocNTM" value='<?php echo CONST_TITLE_CAP_NHAT;?>' onClick="if(test_status_update_dispute(document.forms[0].rad_status,document.forms[0].hdn_work,'<?=$v_num?>')){Update_record_status_dispute('UPDATE_RECORD_STATUS_DISPUTE');}" onKeyDown="change_focus(document.forms[0],this)">
		<?php }?>
			<input type="button" name="btn_back" class="normal_button" value="<?php echo _CONST_BACK_BUTTON;?>" onClick="btn_back_onclick('<?php echo $_GO_BACK?>')" onKeyDown="change_focus(document.forms[0],this)">
			
		</td>
	</tr>
</table>					
</div>
</form>
<script language="JavaScript">
set_focus(document.forms[0]);

</script>
<?php 
//Kiem tra danh sach can bo phe duyet ho so lan 1 co trung voi danh sach can bo phe duyet lan 2 khong
function first_time_handle_leaders_is_handle_leaders($arr_handle_leader_first_time_list, $arr_handle_leader_list) {
	$sz_arr_handle_leader_first_time_list = sizeof($arr_handle_leader_first_time_list);
	$sz_arr_handle_leader_list = sizeof($arr_handle_leader_list);
	if ($sz_arr_handle_leader_first_time_list == $sz_arr_handle_leader_list && $sz_arr_handle_leader_list == 1) {
		if ($arr_handle_leader_first_time_list[0] == $arr_handle_leader_list[0]) {
			return true;
		}
	}
	if ($sz_arr_handle_leader_list == 1) {
		return in_array($arr_handle_leader_list[0], $arr_handle_leader_first_time_list);				
	}
	return false;
}
?>